package Boundry;

import java.awt.EventQueue;

import Boundry.GenericTools.GenericTabel;
import Boundry.GenericTools.IPanelOperation;
import Boundry.GenericTools.InputPanel;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.JTextArea;
import javax.swing.border.TitledBorder;
import javax.swing.UIManager;

public class AddNewInfoSys extends InputPanel implements IPanelOperation {
	
	private JTextField tfInfoName;
	private JTextArea taDescription;
	private GenericTabel table;
	
	public AddNewInfoSys() {
		
		JPanel paInfoSysData = new JPanel();
		paInfoSysData.setBounds(23, 37, 308, 169);
		mainPanel.add(paInfoSysData);
		paInfoSysData.setLayout(null);
		paInfoSysData.setBorder(new TitledBorder(null, "Step 1 :  Insert data of the new Info System", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		
		JLabel lblInfoSystemName = new JLabel("Info System Name");
		lblInfoSystemName.setBounds(10, 35, 100, 14);
		paInfoSysData.add(lblInfoSystemName);
		
		tfInfoName = new JTextField();
		tfInfoName.setBounds(120, 32, 173, 20);
		paInfoSysData.add(tfInfoName);
		tfInfoName.setColumns(10);
		
		JLabel lblNewLabel = new JLabel("Description");
		lblNewLabel.setBounds(10, 76, 100, 14);
		paInfoSysData.add(lblNewLabel);
		
		JTextPane textPane = new JTextPane();
		textPane.setBounds(168, 170, 119, -80);
		paInfoSysData.add(textPane);
		
		taDescription = new JTextArea();
		taDescription.setBounds(120, 77, 173, 74);
		
		taDescription.setLineWrap(true);
		JScrollPane sbrText = new JScrollPane(taDescription);
		sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		sbrText.setBounds( 120, 77, 173, 74);
		paInfoSysData.add(sbrText);
		
		JPanel paSuper = new JPanel();
		paSuper.setBounds(359, 37, 516, 303);
		mainPanel.add(paSuper);
		paSuper.setLayout(null);
		paSuper.setBorder(BorderFactory.createTitledBorder( "Supervisor of Info System"));
		
		table = new  GenericTabel(486, 250, "Workers List");
		table.setBounds(10, 21, 496, 271);
		paSuper.add(table);
		
	}

	public String getInfoSysName()
	{
		return tfInfoName.getText();
	}
	public String getDescription()
	{
		return taDescription.getText();
	}
	
	public void buildTabel(String[] columnNames, String[][] tableData)
	{   
		table.buildTabel( columnNames,  tableData);
	}
	
	public void addRow(String[] row)
	{
		table.addRow( row);
		
	}
	
	public void addColumn(String colName)
	{
		table.addColumn(colName);
	}
	
	public void removeRow(int rowLineNumber)
	{
		table.removeRow(rowLineNumber);
	}
	
	public void removeAllRows()
	{
		table.removeAllRows();
	}
	
    public boolean isChosen() 
    {
    	return table.isChosen() ;
    }
    
    public int getChosen()
    {
    	 return table.getChosen() ;
    }
	
	
	@Override
	public String apHelpButton() 
	{
		//tablepanel_.setBorder(BorderFactory.createTitledBorder( "Request Table"));
		return "Insert new info System to the system";
	}
	
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JFrame frame = new JFrame();
					frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
					frame.setBounds(100, 100, 550, 500);
					AddNewInfoSys b = new AddNewInfoSys();
					frame.getContentPane().add(b);
					frame.setVisible(true);
					
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	@Override
	public String setTitle() {
		return ("Add New Info System");
	}
}
